package com.zengdada.authority.controller;

import com.zengdada.authority.service.AppPowerAuthorityService;
import com.zengdada.authority.utils.JsonMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import static com.zengdada.authority.utils.JsonMessage.fail;
import static com.zengdada.authority.utils.JsonMessage.success;

/**
 * @Auther: 12614
 * @Contact: 1261438511@qq.com
 * @Date: 2018/11/27 20:02
 * @Description:
 */
@Api("导航控制器")
@Controller
@RequestMapping("/authority/nav")
public class NavigationAuthorityController {

    @Autowired
    @Qualifier("appPowerAuthorityServiceImpl")
    AppPowerAuthorityService appPowerService;

    @ApiOperation(value = "菜单数据", notes = "根据当前登录用户的权限获取菜单数据")
    @RequestMapping(value = "/json.do", method = RequestMethod.POST)
    @ResponseBody
    public JsonMessage nav() {
        try {
            return success(appPowerService.getNavigationTree());
        } catch (Exception e) {
            return fail(e.getMessage());
        }
    }
}
